<% layout('/layouts/default.html', {title: 'OCR算法配置管理', libs: ['validate','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(ocrAlgorithmConfig.isNewRecord ? '新增OCR算法配置' : '编辑OCR算法配置')}
			</div>
			<div class="box-tools pull-right hide">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${ocrAlgorithmConfig}" action="${ctx}/ocr/ocrAlgorithmConfig/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="algorithmConfigId"/>
				<#form:hidden path="totalWeight" defaultValue="1.0" placeholder="选中的模型算法之和必须等于1.0" class="form-control number"/>
				<div class="row">
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('算法名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="name" maxlength="200" placeholder="请输入模型名称，见名知意" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('模型算法')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="modelAlgorithm" blankOption="false" blankOptionLabel="请选择模型算法" dictType="ocr_algorithm_items" multiple="true"  class="form-control required" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('模型版本')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="modelVersion" dictType="ocr_model_engine" class="form-control required" />
								
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">${text('算法权重配置')}</div>					
				<div class="row">	
					<div class="form-group">
						<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> <i class="fa icon-question hide"></i></label>
						<div class="col-sm-10">
							<table class="table table-bordered  table-hover">
								<caption>算法权重配置说明</caption>
								<thead>
									<tr>
										<th>样本状态</th>
										<th>推荐算法</th>
										<th>参考说明</th>
									</tr>
								</thead>
								<tbody>
									<tr class="table-primary">
										<td>无样本</td>
										<td>综合评分公式</td>
										<td>f(x)=w1*s1+w2*s2+w1*s3+w3*s3+w4*s4+w5*s5+w6*s6+w7*s7;
											<br />
											<img width="20%" height="20%" src="${ctxStatic}/now.png">
											<a href="${ctxStatic}/综合评分公式.docx" target="_blank" alt="综合评分算法.doc">综合评分算法说明.doc</a>
											<br />
											s1:关键词匹配权重；s2：版式识别权重；s3:大模型提示词权重;<br />
											s4:图片相似度权重;s5:图像分类模型权重;s6:特征区域权重;s7:自训练模型权重;
										</td>
									</tr>
									<tr class="table-secondary">
										<td>少样本</td>
										<td>GAN 对抗增强</td>
										<td>
											样本数量充足时，推荐基于机器学习的决策树、随机森林、集成算法等进行训练。
											<br />
											<img width="50%" height="50%" src="${ctxStatic}/suggest.png">
										</td>
									</tr>
									<tr class="table-success">
										<td>样本丰富</td>
										<td>专业的分类算法</td>
										<td>Adaboost算法、GBDT算法、分类算法 lightgbm、分类算法 xgboost、分类算法 catboost。</td>
									</tr>
								</tbody>
							</table>
																				
						</div>
					</div>					
					
				
					
					
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('关键词匹配权重')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="keywordsWeight" defaultValue="0"  placeholder="选中的模型算法之和必须等于1.0"  class="form-control number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('大模型提示词权重')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="largeModelWeight"  defaultValue="0"  placeholder="选中的模型算法之和必须等于1.0" class="form-control number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('图片相似度权重')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="similarityWeight"  defaultValue="0"  placeholder="选中的模型算法之和必须等于1.0" class="form-control number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('图像分类模型权重')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="classificationWeight"  defaultValue="0"  placeholder="选中的模型算法之和必须等于1.0" class="form-control number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('特征区域权重')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="fixedRegionWeight"  defaultValue="0"  placeholder="选中的模型算法之和必须等于1.0" class="form-control number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('自训练模型权重')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="customTrainingWeight"  defaultValue="0"  placeholder="选中的模型算法之和必须等于1.0" class="form-control number"/>
							</div>
						</div>
					</div>
					
					
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('算法描述')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="description" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				
				
				<div class="form-unit">${text('阈值筛选')}</div>				
				
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('字符阈值')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="ocrCharScores" defaultValue="-1" placeholder="请输入阈值，默认-1。不做任何限制！" class="form-control number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('边框阈值')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="ocrBoxScore" defaultValue="-1" placeholder="请输入阈值，默认-1。不做任何限制！"  class="form-control number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('角度阈值')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="ocrAngleScore" defaultValue="-1" placeholder="请输入阈值，默认-1。不做任何限制！"  class="form-control number"/>
							</div>
						</div>
					</div>
					
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('预览图背景色')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="preBackGroundColor"  defaultValue="BLACK"  blankOptionLabel="请选择背景色,默认随机生成"   dictType="ocr_colors" blankOption="false" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('预览图字体')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="preFontName" dictType="ocr_font_family" blankOption="false" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('预览图字体颜色')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="preFontColor" dictType="ocr_colors" defaultValue="RANDOM"  blankOptionLabel="请选择背景色,默认随机生成"  blankOption="false" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('预览图字体样式')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="preFontStyle" dictType="ocr_font_style" blankOption="false" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('预览图边框颜色')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="preRectangleColor" dictType="ocr_colors" defaultValue="RANDOM"  blankOptionLabel="请选择背景色,默认随机生成"  blankOption="false" class="form-control" />
							</div>
						</div>
					</div>					
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('预览图字体大小')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="preFontSize" maxlength="64" defaultValue="16"   class="form-control number"/>
							</div>
						</div>
					</div>		
					
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="图像外接白框，用于提升识别率，文字框没有正确框住所有文字时，增加此值。默认50。">
								<span class="required ">*</span> ${text('图像外接白框')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="padding" defaultValue="50"  class="form-control digits"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('按图像长边进行总体缩放')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="maxSideLen"  defaultValue="0"  class="form-control required digits"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="按图像长边进行总体缩放，放大增加识别耗时但精度更高，缩小减小耗时但精度降低，maxSideLen为0表示不缩放">
								<span class="required ">*</span> ${text('文字框置信度门限')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="boxScoreThresh" defaultValue="0.5"   class="form-control required number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="框的score阈值，框的score小于这个会被过滤">
								<span class="required ">*</span> ${text('框的score阈值')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="boxThresh" defaultValue="0.3"   class="form-control required number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="单个文字框大小倍率，越大时单个文字框越大">
								<span class="required ">*</span> ${text('单个文字框大小倍率')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="unClipRatio" defaultValue="1.6"   class="form-control required number"/>
							</div>
						</div>
					</div>					
					
								
				</div>	
					
						
					<div class="form-unit">${text('引擎配置')}</div>			
				<div class="row">				
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="默认-1。不做任何限制">
								<span class="required ">*</span> ${text('CPU 核心数量')}：<i class="fa icon-question " ></i></label>
							<div class="col-sm-8">
								<#form:input path="numThread" defaultValue="-1" placeholder="默认-1。不做任何限制！" class="form-control number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="默认-1。不做任何限制;GPU0一般为默认GPU，参数选项：使用CPU(-1)/使用GPU0(0)/使用GPU1(1)/...重要：ONNX不使用GPU，目前都是使用CPU">
								<span class="required ">*</span> ${text('GPU索引')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:input path="gpuIndex" defaultValue="-1" placeholder="默认-1。不做任何限制！" class="form-control number"/>
							</div>
						</div>
					</div>
					
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="启用(true)/禁用(false) 文字方向检测，只有图片倒置的情况下(旋转90~270度的图片)，才需要启用文字方向检测，默认关闭">
								<span class="required ">*</span> ${text('文字方向检测')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:radio path="doAngle" defaultValue="1" dictType="sys_yes_no" class="form-control required digits" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="启用(1)/禁用(0) 角度投票(整张图片以最大可能文字方向来识别)，当禁用文字方向检测时，此项也不起作用，默认关闭">
								<span class="required ">*</span> ${text('角度投票')}：<i class="fa icon-question "></i></label>
							<div class="col-sm-8">
								<#form:radio path="mostAngle" defaultValue="1" dictType="sys_yes_no" class="form-control required digits" />
							</div>
						</div>
					</div>					
					
			  </div>					
					
					
				
		
	
				
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('ocr:ocrAlgorithmConfig:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>